﻿#include "stdafx.h"
#include "XTrackerIntParser.h"

#include "XBSTR.h"
#include "XString.h"
#include "StrUtil.h"
#include "Util.h"
#include "IXColorDraw.h"
#include "IXImageDraw.h"
#include "IXTracker.h"

#include "ParseHelper.h"

#if _IS_UI_DESIGNED_ENABLED_
CXTrackerIntParser::CXTrackerIntParser() : CXIntParserBase(&TIntCreateControl<IXTracker>)
{
    ;
}

CXTrackerIntParser::~CXTrackerIntParser()
{
    ;
}

// 填充属性
BOOL CXTrackerIntParser::FillAttr(IN IXConfigNode* pNode, IN IXControl* pControl)
{
    BOOL bResult = m_ParentParser.FillAttr(pNode, pControl);
    if(!bResult)
        return bResult;

    return bResult;
}

// 创建控件之后
BOOL TryToFindTrackee(IXControl* pChild, LPARAM lParam)
{
    IXFrame* pFrame = dynamic_cast<IXFrame*>(pChild);
    if(pFrame != NULL)
    {
        IXTracker* pTracker = (IXTracker*)lParam;
        pTracker->put_Trackee(pFrame);
        return FALSE;
    }
    return TRUE;
}

BOOL CXTrackerIntParser::PostCreate(IN IXConfigNode* pNode, IN IXControl* pControl)
{
    IXTracker* pTracker = dynamic_cast<IXTracker*>(pControl);
    XASSERT_ERROR(pTracker != NULL, _T("CXTrackerIntParser::PostCreate Failed"));
    pControl->TransverseChilds(&TryToFindTrackee, (LPARAM)pTracker);
    return TRUE;
}

#endif  // #if _IS_UI_DESIGNED_ENABLED_